package com.example.project.key.connection;


import com.mysql.jdbc.Connection;

import java.sql.DriverManager;

public class databaseconn {
    private static final String driver = "com.mysql.jdbc.Driver";
    private static final String url="jdbc:mysql://rm-7xv0w19cvdz7ibm5bao.mysql.rds.aliyuncs.com/projectb?useUnicode=true&characterEncoding=UTF-8&useSSL=false";
    private static final String user = "rcapp";
    private static final String password = "Dai201908";
    public static Connection getConnection()
    {
        Connection conn = null;
        try {
            Class.forName(driver);
            conn = (Connection) DriverManager.getConnection(url,user,password);
            System.out.println("连接数据库成功");
        }catch (Exception e)
        {
            System.out.println(e.getMessage());
            System.out.println("连接数据库失败");
        }
        System.out.println(conn);
        return conn;
    }
}
